package edu.sctu.practice.class01.wulixia.month09_wlx.assign03.one;

/**
 * Created by wulixia on 2015/11/4.
 * 比较圆与梯形对象的面积是否相等，并调用displayGeometricObject方法显示对象信息。
 */
public class TestPolymorphism {

    public static void main(String[] args) {
        GeometricObject circle = new Circle("red",6);
        GeometricObject rectangle = new Rectangle("blue",2,5,3);

        System.out.println("这两个图形的面积相等吗？ " + equalArea(circle, rectangle));
        System.out.println("圆的信息为：");
        displayGeometricObject(circle);
        System.out.println("梯形的信息为：");
        displayGeometricObject(rectangle);

    }

    static boolean equalArea(GeometricObject object1, GeometricObject object2){
        if(object1.findArea() == object2.findArea()){
            return true;
        }else {
            return false;
        }
    }

    static void displayGeometricObject(GeometricObject object){
        System.out.println("颜色为：" + object.color);
        System.out.println("面积是： " + object.findArea());
        System.out.println("周长是： " + object.findPerimeter());

    }

}
